package com.javaspeak.designpatterns.go4.behavioural.visitor;

/**
 * SquareVisitable and TriangleVisitable implement this class.  The calling code
 * in ApplicationVisitor calls the accept method on SquareVisitable and
 * TriangleVisitable two times each. On once occasion it calls passing the
 * SmallShapeVisitor through the accept method and the second time it passes
 * the BigShapeVisitor.  Both SquareVisitable and TriangleVisitable in turn
 * call the visit method on the Visitor classes, SmallShapeVisitor and
 * BigShapeVisitor.
 * <p>
 * The result is a small triangle is drawn when passing the SmallShapeVisitor
 * into the accept method of TriangleVisitable and similarly a small square is
 * drawn when passing the SmallShapeVisitor into the accept method of
 * SquareVisitable.
 * <p>
 * Both the small triangle and small square drawing code is encapsulated in the
 * SmallShapeVisitor instead of being in both TriangleVisitable and
 * SquareVisitable.  What this means is that the TriangleVisitable and
 * SquareVisitable code does not need to change if a new style of drawing a
 * triangle and square (such as in 3D) is invented.  The 3D implementation of
 * both a triangle and square could then be encapsulated in a new Visitor called
 * 3DShapeVisitor.
 * <p>
 * A big triangle is drawn passing the BigShapeVisitor into the the accept
 * method of TriangleVisitable and similarly a big square is drawn
 * passing the BigShapeVisitor into the accept method of  SquareVisitable.
 * Both the big triangle and big square drawing code is encapsulated in the
 * BigShapeVisitor instead of being in both TriangleVisitable and
 * SquareVisitable. This makes it easy to maintain code relating to big shapes
 * across all shapes.
 *
 * @author John Dickerson
 */
public interface ShapeVisitable {

    /**
     * The Calling code, ApplicationVisitor, calls the accept method on
     * TriangleVisitable or SquareVisitable passing in SmallShapeVisitor or
     * BigShapeVisitor. The accept implementation will in turn call one of the
     * overloaded visit methods of SmallShapeVisitor or BigShapeVisitor
     *
     * @param shapeVisitor The ShapeVisitor, either SmallShapeVisitor or
     * BigShapeVisitor, to call the overloaded visit method on, and in so
     * doing draw a shape.
     */
    void accept( ShapeVisitor shapeVisitor );
}